package com.edu.hre.struts.form.leave;

import java.io.Serializable;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.apache.struts.util.LabelValueBean;

import com.edu.hre.common.utils.CommonUtils;
import com.edu.hre.db.pojo.HreLeaveType;
import com.edu.hre.struts.action.leave.LeaveRequestUpdateAction;

public class LeaveRequestForm implements Serializable { 
	/**
	 * 
	 */
	private static final SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy  HH:mm");
	private static final SimpleDateFormat dateFormat_ = new SimpleDateFormat("MM/dd/yyyy  HH_:mm");
	private static final long serialVersionUID = -8483852353127690666L;

	private Integer id;
	private int empNum;
	private Date firstLeave;
	private Date lastLeave;
	private int supervisorNum;
	private String supervisorFullName;
	private Boolean approved;
	private int leaveTypeId;
	private String leaveTypeName; 
	private String empComment;
	private String supComment;  
	private Float totalLeaved;

	private boolean isSelected = false;
	private String message = "";
	private boolean isAddNew = true;

	public LeaveRequestForm() {
	}
 

	public LeaveRequestForm(Integer id2, int empNum2, Date firstLeave2, Date lastLeave2,
			int supervisorNum2, Boolean approved2, int leaveTypeId2, String empComment, String supComment) {
		this.id = id2;
		this.empNum = empNum2;
		this.firstLeave = firstLeave2;
		this.lastLeave = lastLeave2;
		this.supervisorNum = supervisorNum2;
		this.approved = approved2;
		this.leaveTypeId = leaveTypeId2;
		this.setEmpComment(empComment);
		this.setSupComment(supComment);
	}
 

	public String getTotalLeavedStr(){
		DecimalFormat df = new DecimalFormat("0.0");
		return df.format(getTotalLeaved());
	} 
	
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public int getEmpNum() {
		return this.empNum;
	}

	public void setEmpNum(int empNum) {
		this.empNum = empNum;
	}

	public Date getFirstLeave() {
		return this.firstLeave;
	}

	public void setFirstLeave(Date firstLeave) {
		this.firstLeave = firstLeave;
	}

	public String getFirstLeaveStr() {
		if (this.firstLeave == null) {
			return "";
		}
		return dateFormat_.format(this.firstLeave).replace("_", "h");
	}

	public void setFirstLeaveStr(String firstLeave) {
		try {
			this.firstLeave = dateFormat.parse(firstLeave);
		} catch (Exception e) {
			CommonUtils.println(e.getMessage());
		}
	}

	public Date getLastLeave() {
		return this.lastLeave;
	}

	public void setLastLeave(Date lastLeave) {
		this.lastLeave = lastLeave;
	}

	public String getLastLeaveStr() {
		if (this.lastLeave == null) {
			return "";
		}
		return dateFormat_.format(this.lastLeave).replace("_", "h");
	}

	public void setLastLeaveStr(String lastLeave) {
		try {
			this.lastLeave = dateFormat.parse(lastLeave);
		} catch (Exception e) {
			CommonUtils.println(e.getMessage());
		}
	}

	public int getSupervisorNum() {
		return this.supervisorNum;
	}

	public void setSupervisorNum(int supervisorNum) {
		this.supervisorNum = supervisorNum;
	}

	public Boolean getApproved() {
		return this.approved;
	}

	public void setApproved(Boolean approved) {
		this.approved = approved;
	}

	public int getLeaveTypeId() {
		return this.leaveTypeId;
	}

	public void setLeaveTypeId(int leaveTypeId) {
		this.leaveTypeId = leaveTypeId;
	}

	public boolean isSelected() {
		return isSelected;
	}

	public void setSelected(boolean isSelected) {
		this.isSelected = isSelected;
	}

	public boolean getIsSelected() {
		return isSelected;
	}

	public void setIsSelected(boolean isSelected) {
		this.isSelected = isSelected;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public boolean isAddNew() {
		return isAddNew;
	}

	public void setAddNew(boolean isAddNew) {
		this.isAddNew = isAddNew;
	}

	public boolean getIsAddNew() {
		return isAddNew;
	}

	public void setIsAddNew(boolean isAddNew) {
		this.isAddNew = isAddNew;
	}

	public String getSupervisorFullName() {
		return supervisorFullName;
	}

	public void setSupervisorFullName(String supervisorFullName) {
		this.supervisorFullName = supervisorFullName;
	}

	public String getLeaveTypeName() {
		return leaveTypeName;
	}

	public void setLeaveTypeName(String leaveTypeName) {
		this.leaveTypeName = leaveTypeName;
	} 

	public Float getTotalLeaved() {
		if(totalLeaved != null){
			return totalLeaved;
		}
		try {
			return LeaveRequestUpdateAction.computeLeaveDays(firstLeave, lastLeave);	
		} catch (Exception e) {
			CommonUtils.println(e.getMessage());
		}
		return null;
	}


	public void setTotalLeaved(Float totalLeaved) {
		this.totalLeaved = totalLeaved;
	}


	public String getSupComment() {
		return supComment;
	}


	public void setSupComment(String supComment) {
		this.supComment = supComment;
	}


	public String getEmpComment() {
		return empComment;
	}


	public void setEmpComment(String empComment) {
		this.empComment = empComment;
	}


}
